<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>节目选择</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link href="../../static/css/uploadify.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script src="../../static/js/jquery.uploadify.js" type="text/javascript"></script>
<%
	String para =request.getParameter("index");
	int index = 0;
	if(para != null)
		index = Integer.valueOf(para);
	String []nonceObj=ConstantUtils.getNonceObject();
%>
<script type="text/javascript">
		var index = <%=index%>;
		var queryParams;
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				url: '../../content/content_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'f_cc_id',title:'节目ID',align:'center',width:100},
					{field:'f_cc_name',title:'节目名称',align:'center',width:300},
					{field:'f_cc_type',title:'节目类型',align:'center',width:100,
						formatter:function(value,row,index) {
							var status = "未知";
							if(value==2){
								status="视频";
							}else if(value==3){
								status="频道";
							}else if(value==4){
								status="图文";
							}
							return status;
						}	
					},
					{field:'f_cc_cdate',title:'创建时间',align:'center',width:200,
						formatter:function(value,row,index) {
							var str = "";
							if(value!=null)
								str = value.substring(0,19);
							return str;
						}	
					}
				]],
				singleSelect:true,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				onExpandRow: function(index,row){
					
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function(data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/login.do';
						    return false;
						}});
					}
				}
			});
		}
		
		function getGueryParams(){
			var types = $("#f_cc_types").val();
			if($("#f_cc_type").val() && parseInt($("#f_cc_type").val()) > 0) {
				types = $("#f_cc_type").val();
			}
			
			return {
				f_cc_name:$("#f_cc_name").val(),
				f_cc_status:$("#f_cc_status").val(),
				f_cc_types:types
			};
		}
		$(function(){
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			
		});
		function updateContent(){
			var rowInfo = $("#easyui-datagrid").datagrid('getSelected');
			if(rowInfo==null){
				$.messager.alert('提示', "您未选择节目", 'info', function() {
					$.messager.progress('close');
				});
				return;	
			}
			window.parent.document.getElementById("f_cc_name"+index).value=rowInfo.f_cc_name;
			window.parent.document.getElementById("f_cc_id"+index).value=rowInfo.f_cc_id;
	        parent.$('#content_list').dialog('close')
		}
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
</script>
</head>
<body>
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="节目列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<input type="hidden" name="stime" value="<%=nonceObj[0]%>"/>
				<input type="hidden" name="sign" value="<%=nonceObj[1]%>"/>
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left" width="7%">节目名称：</td>
						<td align="left" width="10%"><input name="f_cc_name" id="f_cc_name" style="width: 150px;"  onkeydown="onpress();"/></td>
						<td align="left" width="7%">节目类型：</td>
						<td align="left" width="10%">
							<select id="f_cc_type" name="f_cc_type">
									<option value="0">请选择</option>
									<option value="2">视频</option>
									<option value="3">频道</option>
									<option value="4">图文</option>
							</select>
						</td>
						<input type="hidden" id="f_cc_status" name="f_cc_status"  value="1"/>
						<input type="hidden" id="f_cc_types" name="f_cc_types"  value="2,3,4"/>
						<td align="left" width="10%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
						<td align="right" width="10%">
							<a id="easyui-linkbutton" class="easyui-linkbutton"
							data-options="iconCls:'icon-ok'" href="javascript:void(0);"
							onclick="updateContent()">确认</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>		
</body>
</html>